package com.yijianonghu.service.wxwebsite.message;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.yijianonghu.dal.model.SysNotice;
import com.yijianonghu.dal.model.SysNoticeExample;

import net.javahub.dao.BaseSqlDao;
import net.javahub.dao.BaseSqlDao.SqlWrapper;
import net.javahub.service.BaseService;

@Service
public class SystemNoticeService extends BaseService<SysNotice, Integer, SysNoticeExample> {

	@Autowired
	private BaseSqlDao baseSqlDao;
	
	//系统通知
	public List<Map<String, Object>> getSystemNotice(Integer userId, String orderBy){
		StringBuilder sb=new StringBuilder("select sn.keyid, sn.content, sn.looktype, sc.avatar from sys_notice sn");
		sb.append(" left join sys_client sc on sn.client_id=sc.id")
			.append(" where sn.keytype is not null")
			.append(" and sn.keytype not in (#{params.keytype})")
			.append(" and sn.client_id is not null")
			.append(" and sn.client_id=#{params.client_id}")
			.append(" order by sn."+orderBy);
		SqlWrapper wrapper=new SqlWrapper();
		wrapper.setSqlStatement(sb.toString());
		wrapper.addParam("keytype", "2,3");
		wrapper.addParam("client_id", userId);
		return baseSqlDao.select(wrapper);		
	}
}
